package main

import (
	"fmt"
)

func escForeColor(color string) string {
	if color == "black" {
		return "30"
	} else if color == "red" {
		return "31"
	} else if color == "green" {
		return "32"
	} else if color == "yellow" {
		return "33"
	} else if color == "blue" {
		return "34"
	} else if color == "magenta" {
		return "35"
	} else if color == "cyan" {
		return "36"
	} else if color == "white" {
		return "37"
	} else if color == "grey" {
		return "30;1"
	} else if color == "bright_red" {
		return "31;1"
	} else if color == "bright_green" {
		return "32;1"
	} else if color == "bright_yellow" {
		return "33;1"
	} else if color == "bright_blue" {
		return "34;1"
	} else if color == "bright_magenta" {
		return "35;1"
	} else if color == "bright_cyan" {
		return "36;1"
	} else if color == "bright_white" {
		return "37;1"
	} else {
		panic("Illegal color: " + color)
	}
}

func style(fg, format string, args ...interface{}) string {
	return "\033[" + escForeColor(fg) + "m" + fmt.Sprintf(format, args...) + "\033[0m"
}
